package DB.Inscricao;

public abstract class InscricaoTable {

    /**
     * NOME DA TABELA *
     */
    public static final String TABLE_NAME = "inscricoes";
    
    /**
     * COLUNAS *
     */
    public static final String COLUMN_ID = "id";
    public static final String COLUMN_IDEVENTO = "idEvento";
    public static final String COLUMN_IDPARTICIPANTE = "idParticipante";
    public static final String COLUMN_DATAINSCRICAO = "dataInscricao";
    
    public static final String[] allColumns = { COLUMN_ID, COLUMN_IDEVENTO, COLUMN_IDPARTICIPANTE, COLUMN_DATAINSCRICAO };
    
    /**
     * TIPOS E SEPARADORES *
     */
    private static final String INT_TYPE = " INTEGER";
    private static final String TEXT_TYPE = " TEXT";
    private static final String COMMA_SEP = ", ";
    private static final String NOT_NULL = " NOT NULL ";
    
    /**
     * CRIAÇÃO DE INDEX *
     */
    public static final String CREATE_INDEX_ID_ID =
            "CREATE UNIQUE INDEX IF NOT EXISTS idx_inscricoes ON " + TABLE_NAME + "("
            + COLUMN_IDEVENTO + " ASC, "
            + COLUMN_IDPARTICIPANTE + " ASC"
            + ");";
    
    /**
     * CRIAÇÃO DA TABELA *
     */
    public static final String TABLE_CREATE =
            "CREATE TABLE IF NOT EXISTS " + TABLE_NAME + "("
            + COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT" + NOT_NULL + COMMA_SEP
            + COLUMN_IDEVENTO + INT_TYPE + NOT_NULL + "CONSTRAINT 'FK_Inscricao_Evento' REFERENCES eventos ( id )" + COMMA_SEP
            + COLUMN_IDPARTICIPANTE + INT_TYPE + NOT_NULL + "CONSTRAINT 'FK_Inscricao_Usuario' REFERENCES usuarios ( id )" + COMMA_SEP
            + COLUMN_DATAINSCRICAO + TEXT_TYPE + NOT_NULL// + COMMA_SEP
//            + "FOREIGN KEY(" + COLUMN_IDEVENTO + ") REFERENCES " + EventoTable.TABLE_NAME + "(" + EventoTable.COLUMN_ID + "), "
//            + "FOREIGN KEY(" + COLUMN_IDPARTICIPANTE + ") REFERENCES " + UsuariosTable.TABLE_NAME + "(" + UsuariosTable.COLUMN_ID + ")"
            + ");";
    
    public static final String DELETE_ALL = "DELETE FROM " + TABLE_NAME;
}